package homework.mission5;

public class Board {
    public static void main(String[] args) {
        String[][] board = createChessBoard(16, 16);
        print(board);
    }

    /**
     *
     * @param row 棋盘的行数
     * @param column 棋盘的列数
     * @return
     */
    public static String[][] createChessBoard(int row, int column) {
        // 判断棋盘的行数和列数
        if(row > 16 || column > 16) {
            throw new RuntimeException("参数错误");
        }
        String[][] chess_board = new String[row][column];
        String[] str_arr = {"0", "1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};

        //棋盘的第一行
        for (int i = 0; i < chess_board[0].length; i++) {
            chess_board[0][i] = str_arr[i];
        }

        //棋盘的第一列
        for (int i = 0; i < chess_board.length; i++) {
            chess_board[i][0] = str_arr[i];
        }

        for (int i = 1; i < chess_board.length; i++) {
            for (int j = 1; j < chess_board[i].length; j++) {
                chess_board[i][j] = "+";
            }
        }

        return chess_board;
    }

    public static void print(String[][] board) {
        for (int i = 0; i < board.length; i++) {
            for (int j = 0; j < board[i].length; j++) {
                System.out.print(board[i][j]);
            }
            System.out.println();
        }
    }
}
